const toast = {
    show(id, msg) {
        let root = $(id);
        root.append('<div class="mask"><div class="loader-box"><div class="toast"><i class="icon icon-exclamation-sign"></i>' + msg + '</div></div></div>');
        setTimeout(() => {
            root.children('div.mask').remove();
        }, 2000)
    }
};

const loading = {
    display(id) {
        let root = $(id);
        let elm = '<div class="mask"><div class="loader">' + 'loading...' + '</div></div>';
        root.append(elm)
    },
    hide(id) {
        let root = $(id);
        let elm = root.children('div.mask');
        elm.remove();
    }
};

const loadingIt = {
    do(id, type) {
        if (id === undefined) id = '#app';
        let root = $(id);
        if (root.length === 0) return;
        if (type === 1) {
            root.append('<div class="mask"><div class="loader-box"><div class="loader">' + 'loading...' + '</div></div></div>');
        } else {
            let elm = root.children('div.mask');
            elm.remove();
        }
    }
};

export default {toast, loading, loadingIt}